home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ETO Development Tools 4
/
ETO Development Tools 4.iso
/
Tools - Objects
/
ResEdit
/
ResEdit 2.1
/
Examples
/
PExamples
/
Source
/
ICON.LDEF.p
next >
Wrap
Text File
|
1990-12-06
|
2KB
|
74 lines
{
COPYRIGHT (C) 1984-1990 Apple Computer,Inc.
All rights reserved
}
UNIT IconLDEF;
INTERFACE
Uses MemTypes, QuickDraw, OSIntf, ToolIntf, PackIntf,
ResEd;
PROCEDURE DrawCell( Message: INTEGER; lSelect: BOOLEAN; lRect: Rect; lCell: Point;
lDataOffset, lDataLen: INTEGER; lh: ListHandle );
IMPLEMENTATION
PROCEDURE DrawIcon (lRect: Rect; theIcon: Handle);
CONST IconSize = 128;
BEGIN
IF (SizeResource(theIcon) >= IconSize) THEN
PlotIcon(lRect, theIcon);
END;
{ This is the custom drawProc for the list (which contains the resource ID's). It
simply draws the icon in the given rect and frames a selection rect around it if
told to.
NOTE: This is used by both ICON and ICN# pickers. }
PROCEDURE DrawCell(Message: INTEGER; lSelect: BOOLEAN; lRect: Rect; lCell: Point;
lDataOffset, lDataLen: INTEGER; lh: ListHandle);
VAR
theIcon: Handle;
id: INTEGER;
wasLoaded: BOOLEAN;
{ This routine simply looks up in the list at the given cell, extracts the ID and
gets the resource called for. Returns NIL if not found. Note, this assumes
the resfile is set up correctly }
FUNCTION IconFetch(lCell: point; lHandle: ListHandle): Handle ;
VAR
len: INTEGER;
err: OsErr;
tempH:Handle;
BEGIN
IconFetch := NIL;
len:=2;
LGetCell(@id, len, lCell, lHandle); { Get the ID from the list. }
IF len > 0 THEN
BEGIN { Load the resource since we want to draw it. }
tempH := REGet1ResourceSpecial(PickHandle(lHandle^^.refCon)^^.theResFile, PickHandle(lHandle^^.refCon)^^.rType, id, wasLoaded, err);
IconFetch := tempH;
END;
END;
BEGIN { DrawCell }
CASE message OF
lDrawMsg, lHiliteMsg:
BEGIN
theIcon := IconFetch(lCell, lh);
DrawLDEF (message, lSelect, lRect, theIcon, id, '', 32, 32, @DrawIcon, lh);
IF (theIcon <> NIL) & (NOT wasLoaded) THEN
HPurge(theIcon);
END;
END;
END;
END.